<%@page import="vlms.bean.SimpleCustomer" %>
<%@page import="vlms.bean.PremiumCustomer" %>
<%@page import="vlms.bean.Person" %>
<%@page import="vlms.bean.Account" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <script TYPE="text/javascript">
      function emailcheck(str) {

    	  var at="@";
    	  var dot=".";
    	  var lat=str.indexOf(at);
    	  var lstr=str.length;
    	  var ldot=str.indexOf(dot);
    	  if (str.indexOf(at)==-1){
    	  alert("Invalid E-mail ID");
    	  return false;
    	  }

    	  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    	  alert("Invalid E-mail ID");
    	  return false;
    	  }

    	  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    	  alert("Invalid E-mail ID");
    	  return false;
    	  }

    	  if (str.indexOf(at,(lat+1))!=-1){
    	  alert("Invalid E-mail ID");
    	  return false;
    	  }

    	  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    	  alert("Invalid E-mail ID");
    	  return false;
    	  }

    	  if (str.indexOf(dot,(lat+2))==-1){
    	  alert("Invalid E-mail ID");
    	  return false;
    	  }

    	  if (str.indexOf(" ")!=-1){
    	  alert("Invalid E-mail ID");
    	  return false;
    	  }
    	 
    	  return true;
    	  }
      
      function validateZIP(field) {
    	  var valid = "0123456789-";
    	  var hyphencount = 0;

    	  if (field.length!=5 || field.length!=10) {
    	  alert("Please enter your 5 digit or 5 digit+4 zip code.");
    	  return false;
    	  }
    	  for (var i=0; i < field.length; i++) {
    	  temp = "" + field.substring(i, i+1);
    	  if (temp == "-") hyphencount++;
    	  if (valid.indexOf(temp) == "-1") {
    	  alert("Invalid characters in your zip code.  Please try again.");
    	  return false;
    	  }
    	  if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
    	  alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
    	  return false;
    	     }
    	  }
    	  return true;
    	  }

    	 
     
      function validate(){
     
      if(document.signUp.firstname.value=="")
      {
   alert("Please enter first name");
   document.signUp.firstname.focus();
   return false;
      }
      if(document.signUp.lastname.value=="")
      {
   alert("Please enter last name");
   document.signUp.lastname.focus();
   return false;
      }
      if(document.signUp.username.value=="")
      {
   alert("Please enter username");
   document.signUp.username.focus();
   return false;
      }
      if(document.signUp.password.value=="")
      {
   alert("Please enter password");
   document.signUp.password.focus();
   return false;
      }
     
     
      var emailID=document.frm.email;

	  if ((emailID.value==null)||(emailID.value=="")){
	  alert("Please Enter your Email Address");
	  emailID.focus();
	  return false;
	  }
	  
	  if (emailcheck(emailID.value)==false){
	  emailID.value="";
	  emailID.focus();
	  return false;
	  }
	 
      if(document.signUp.state.value=="")
     {
   alert("Please select state");
   document.signUp.state.focus();
   return false;
      }
      if(document.signUp.city.value=="")
      {
   alert("Please enter city");
   document.signUp.city.focus();
   return false;
      }
      
      var zpcode=document.signUp.zipcode;

	  if ((zpcode.value==null)||(zpcode.value=="")){
	  alert("Please Enter  zipcode");
	  zpcode.focus();
	  return false;
	  }
	  
	  if (validateZIP(zpcode.value)==false){
	  zpcode.value="";
	  zpcode.focus();
	  return false;
	  }
     
      if(document.signUp.memtype.value=="")
      {
   alert("Please select member type");
   document.signUp.memtype.focus();
   return false;
      }
      if(document.signUp.credit_no.value=="")
      {
   alert("Please enter creditcard no");
   document.signUp.credit_no.focus();
   return false;
      }

      if(document.signUp.creditcard_type.value=="")
      {
   alert("Please enter credit card type");
   document.signUp.creditcard_type.focus();
   return false;
      } 
      if(document.signUp.Cvvnumber.value=="")
      {
    	   alert("Please enter cvv number");
    	   document.signUp.Cvvnumber.focus();
    	   return false;
    	      }
      
      return true;
                
 }
      </script>

<%@ include file="/title.html" %>
</head>
<body>
<table width="100%">
<%@ include file="/header.jsp" %>

<tr valign="top"><td align="center" height="300px">
<table width="100%">

<tr valign="top" height="50px">
<td align="center">
<%@ include file="/headerLinks.jsp" %>
</td>
</tr>
<tr><td align="center" height="40px" colspan="2" valign="top"><h3>Profile</h3></td></tr>
<% if(request.getAttribute("message") != null) { %>
<tr><td align="center" style="color:red" colspan="2" height="40px" valign="top"><%= request.getAttribute("message") %></td></tr>
<% } %>

<% SimpleCustomer oSC = (SimpleCustomer)session.getAttribute("SimpleCustomer");
PremiumCustomer oPC = (PremiumCustomer)session.getAttribute("PremiumCustomer");
Person oPerson = (Person)session.getAttribute("Person");
Account oAccount = (Account)session.getAttribute("Account");
%>

<form name="signUp" action="SignUp" method="post" onsubmit="return validate();">

<tr>
<td align="left">First Name:</td>

<td><input type="text" name="firstname" value="<%=oPerson.getFirstname() %>"></td>
</tr>
<tr>
<td align="left">Last Name:</td>
<td><input type="text" name="lastname" value="<%=oPerson.getLastname() %>"></td>
</tr>
<tr>
<td align="left">Username: </td>
<td><input type="text" name="username" value="<%=oAccount.getUsername() %>"></td>
</tr>
<tr>
<td align="left">Password: </td>
<td><input type="password" name="password" value="<%=oAccount.getPassword() %>"></td>
</tr>
<tr>
<td align="left">Email Id: </td>
<td><input type="text" name="email" value="<%=oPerson.getEmailid() %>"></td>
</tr>
<tr>
<td align="left">Address: </td>
<td><textarea name="address"><%=oPerson.getAddress()%></textarea></td>
</tr>
<tr>
<td align="left">City: </td>
<td><input type="text" name="city" id="city" value="<%=oPerson.getCity() %>"></td>
</tr>
<tr>
<td align="left">State: </td>
<td><select name="state" size="1">
    <option value="AL">Alabama</option>
    <option value="AK">Alaska</option>
    <option value="AZ">Arizona</option>
    <option value="AR">Arkansas</option>
    <option value="CA">California</option>
    <option value="CO">Colorado</option>
    <option value="CT">Connecticut</option>
    <option value="DE">Delaware</option>
    <option value="DC">Dist of Columbia</option>
    <option value="FL">Florida</option>
    <option value="GA">Georgia</option>
    <option value="HI">Hawaii</option>
    <option value="ID">Idaho</option>
    <option value="IL">Illinois</option>
    <option value="IN">Indiana</option>
    <option value="IA">Iowa</option>
    <option value="KS">Kansas</option>
    <option value="KY">Kentucky</option>
    <option value="LA">Louisiana</option>
    <option value="ME">Maine</option>
    <option value="MD">Maryland</option>
    <option value="MA">Massachusetts</option>
    <option value="MI">Michigan</option>
    <option value="MN">Minnesota</option>
    <option value="MS">Mississippi</option>
    <option value="MO">Missouri</option>
    <option value="MT">Montana</option>
    <option value="NE">Nebraska</option>
    <option value="NV">Nevada</option>
    <option value="NH">New Hampshire</option>
    <option value="NJ">New Jersey</option>
    <option value="NM">New Mexico</option>
    <option value="NY">New York</option>
    <option value="NC">North Carolina</option>
    <option value="ND">North Dakota</option>
    <option value="OH">Ohio</option>
    <option value="OK">Oklahoma</option>
    <option value="OR">Oregon</option>
    <option value="PA">Pennsylvania</option>
    <option value="RI">Rhode Island</option>
    <option value="SC">South Carolina</option>
    <option value="SD">South Dakota</option>
    <option value="TN">Tennessee</option>
    <option value="TX">Texas</option>
    <option value="UT">Utah</option>
    <option value="VT">Vermont</option>
    <option value="VA">Virginia</option>
    <option value="WA">Washington</option>
    <option value="WV">West Virginia</option>
    <option value="WI">Wisconsin</option>
    <option value="WY">Wyoming</option>
</select></td>
</tr>

<tr>
<td align="left">Zipcode: </td>
<td><input type="text" name="zipcode" id="zipcode" value="<%=request.getParameter("zipcode")!=null?request.getParameter("zipcode"):"" %>"></td>
</tr>

<tr>
<td align="left">City: </td>
<td> <INPUT TYPE="radio" NAME="Membertype" id="memtype" value="SimpleCustomer" CHECKED>
             Simple Customer           <BR>
            <INPUT TYPE="radio" NAME="Membertype" id="memtype" value="PremiumCustomer">
            Premium Member
            <BR></td>
</tr>

<tr>
<td align="left">Credit Card Number: </td>
<td><input type="text" name="creditcardno" id="credit_no" value="<%=request.getParameter("creditcardno")!=null?request.getParameter("creditcardno"):"" %>"></td>
</tr>

<tr>
<td align="left">Credit Card Type: </td>
<td><SELECT id="creditcard_type" name="creditcard_type">
      <option value="Visa">Visa<option>
      <option value="Mastercard">Mastercard<option>
      <option value="American Express">American Express<option>
      </SELECT></td>
</tr>

<tr>
<td align="left">CVV Code: </td>
<td><input type="text" name="Cvvnumber" id="Cvvnumber" value=""></td>
</tr>



<tr>
<td height="5px">
</td>
</tr>
<tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="register" value="Register">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</form>
<tr>
<td colspan="2" align="center">
<form name="cancel" action="signIn.jsp" method="post">
<input type="submit" name="cancel" value="Go Back and Sign In">
</form>
</td>
</tr>
</table>
</td>
</tr>
<%@ include file="/bottom.html" %>
</table>
</body>
</html>